This isn’t hard or hacky, just confusing to a n00b. Views and Routes have events added to them differently, but the real trick is that actions don’t seem to hit the view from whom’s template they originated.
View
App.RequestQuoteView = Ember.View.extend({
templateName: '_requestQuoteView',
sendRequest: function(e) {
alert("I should be triggered! from View.");
}
});
Route
App.ProjectRoute = Ember.Route.extend({
model: function() {
return {};
},
events: {
// I am only here for illustration, and do not need to exist.
sendRequest: function(e) {
alert("I should not be triggered! from Route.");
}
}
});
HTML
<button class="btn btn-primary btn-large">Send Request</button>
This works because ‘view’ is a valid property of the controller; an instance of RequestQuoteView. I do not fully understand how things are wired up in the hierarchy, but it seems pretty analogous to anything else with bubbling handlers. See this guide page, under relative paths for some more info—though it’s fairly incomplete; maybe there is some better event documentation out there?